<?php

use yii\helpers\Url;

/* @var $this yii\web\View */
/* @var $model backend\models\AdminUser */
$this->title = '跑广马，抓PB兔';
?>
<script src="/js/jquery.min.js"></script>
<section class="page-section pbt page-column">

    <!-- header -->
    <header></header>

    <main class="pb-form">
        <form action="/index.php?r=site/sign" method="post">
            <div class="pb-form-flex">
                <label>姓名：</label>
                <input name="name" type="text" id="name">
            </div>
            <div class="pb-form-flex">
                <label>手机：</label>
                <input name="mobile" type="tel" id="mobile">
            </div>
            <div class="pb-form-flex">
                <label>广马号码：</label>
                <input type="text" name="number" id="number">
            </div>
            <div class="pb-form-flex">
                <input type="button" id="submit" style="width: 100%" value="报名">
            </div>
        </form>
    </main>

    <!-- title -->
    <h1 class="title">快抓，666只PB兔！</h1>

    <!-- back -->
    <div class="back"></div>

    <!-- aside -->
    <aside></aside>

</section>


<script>
    $(function(){

        $('#submit').click(function(){
            var mobile = $('#mobile').val();
            var name = $('#name').val();
            var number = $('#number').val();
            var _csrf = '<?= Yii::$app->request->csrfToken ?>';
            $.post('/index.php?r=/site/sign', {mobile:mobile, name:name, number:number, "_csrf-frontend":_csrf}, function(data){
                if( data.success == 'ok' ){
                    window.location.href = '/index.php?r=/site/success&sort=' + data.data.sort;
                }else{
                    alert(data.msg);
                }
            }, 'json');
        })

    })
</script>
